package com.ticket.sass.common.entity.tenant;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * <p>
 * 
 * </p>
 *
 * @author ywb
 * @since 2024-03-06
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("film_schedules")
@ApiModel(value="FilmSchedulesEntity对象")
public class FilmScheduleEntity implements Serializable {

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "系统商排期 id")
    private String scheduleKey;

    @ApiModelProperty(value = "影厅")
    private String hall;

    @ApiModelProperty(value = "影片名")
    private String filmName;
    
    @ApiModelProperty(value = "放映时间")
    private LocalDateTime startTime;

    @ApiModelProperty(value = "语言")
    private String lang;

    @ApiModelProperty(value = "放映版本")
    private String version;
    
    @ApiModelProperty(value = "结束时间")
    private LocalDateTime endTime;

    @ApiModelProperty(value = "影厅编码")
    private String hallCode;

    @ApiModelProperty(value = "影片编码")
    private String filmCode;

    @ApiModelProperty(value = "场次编码（专资编码）")
    private String sessionCode;

    @ApiModelProperty(value = "最低发行价")
    private BigDecimal lowestPrice;

    @ApiModelProperty(value = "标准票价")
    private BigDecimal standardPrice;

    @ApiModelProperty(value = "服务费")
    private BigDecimal serviceFee;

    @ApiModelProperty(value = "座位图版本号（凤凰云智）")
    private String seatVersion;

    @ApiModelProperty(value = "场次最后更新时间（鼎新）")
    private String lastUpdateTime;

    @ApiModelProperty(value = "售价（不为空则优先级高于所有票价方案）")
    private BigDecimal salePrice;
    
    @ApiModelProperty(value = "影片 id")
    private Long filmId;

    @ApiModelProperty(value = "影厅 id")
    private Long hallId;

    @ApiModelProperty(value = "影院 id")
    private Long cinemaId;

    @ApiModelProperty(value = "租户 id")
    private Long tenantId;
    
    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    public LocalDateTime createdAt;
    
    @ApiModelProperty(value = "更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    public LocalDateTime updatedAt;
    
    @TableField(select = false)
    @ApiModelProperty(value = "删除时间")
    @TableLogic(value = "null", delval = "now()")
    public LocalDateTime deletedAt;
    
    @TableField(exist = false)
    private String filmCover;
    
    @TableField(exist = false)
    private FilmEntity film;

    @TableField(exist = false)
    private FilmVersionEntity filmVersion;

    @TableField(exist = false)
    private HallEntity hallEntity;

    @TableField(exist = false)
    private CommodityDispatchHallEntity commodityDispatchHall;

    /**
     * 验证场次是否已过售卖时间
     *
     * @return Boolean
     */
    public Boolean isExpired() {
        return this.startTime.isBefore(LocalDateTime.now());
    }
    
    public LocalDate getStartTimeLocalDate() {
        return startTime.toLocalDate();
    }
}
